<!-- 首页 -->
<template>
    <view class="home-wrap u-m-b-20">
        <view class="content-box">
            <view class="u-m-t-20 u-flex u-row-between u-row-col" style="font-size: 32rpx">
                <view class="u-flex">{{ myGroupList.length > 0 ? myGroupList[0].class_name : '' }}</view>
                <view class="u-flex u-row-right">
                    <view style="color: #3FA897">
                        总人数：{{classnum}}人
                    </view>
                    <view class="u-m-l-20" style="color: #3FA897">
                        未绑定：{{braceletnum}}人
                    </view>
                </view>
            </view>
            <view class="u-p-20 shouhuan-tishi u-m-t-20 u-m-b-20">
                红色名字，表示该学生未绑定手环，请老师在登录电脑平台进行绑定
            </view>
            <view v-if="!isEmpty" class="u-m-t-20">
                <view class="collect-list u-flex u-w-100s u-row-between collect-list-top u-p-t-20 u-p-b-20">
                    <view class="xuhao u-flex u-row-center">序号</view>
                    <view class="xuehao u-flex u-row-center">学生姓名(学籍号)</view>
                    <view class="isbangding u-flex u-row-center">是否绑定</view>
                    <view class="shouhuan u-flex u-row-center">绑定手环</view>
                </view>
                <view class="collect-list u-flex u-w-100s u-row-between u-p-t-20 u-p-b-20" v-for="(goods, index) in myGroupList" :key="index">
                    <view class="xuhao u-flex u-row-center">{{index+1}}</view>
                    <view class="xuehao u-flex u-row-center">{{goods.realname}}({{goods.roll}})</view>
                    <view class="isbangding u-flex u-row-center" :style="{color:goods.bracelet?'':'#FA3E3E'}">{{goods.bracelet?'是':'否'}}</view>
                    <view class="shouhuan u-flex u-row-center" style="color: #FA3E3E" v-if="!goods.bracelet">
                        手环标签(空)
                    </view>
                    <view class="shouhuan u-flex u-flex-col u-row-center u-col-center" v-if="goods.bracelet">
                        <view>手环标签</view>
                        <view style="color:#B5B5B5;">（{{goods.bracelet}}）</view>
                    </view>
                </view>
            </view>

            <!-- 数据为空 -->
            <shopro-empty v-if="isEmpty" :image="API_URL() + '/images/empty.png'" tipText="暂无班级成员~">
            </shopro-empty>
            <!-- 更多 -->
            <u-loadmore v-show="!isEmpty" height="80rpx" :status="loadStatus" icon-type="flower" color="#ccc"/>
        </view>
    </view>
</template>

<script>
let systemInfo = uni.getSystemInfoSync();
import {mapGetters} from 'vuex';
import {API_URL} from '@/env'

export default {
    components: {},
    data() {
        return {
            stickyTop    : 0,
            searchVal    : '',
            isChoosed    : false,
            isEmpty      : false,
            isRefresh    : true,
            isScorll     : false,
            showDetel    : false,
            showModal    : false,
            myGroupList  : [],
            tagList      : [],
            tagchecked   : '',
            position     : "",
            tagindex     : '',
            isedit       : false,
            loadStatus   : 'loadmore', //loadmore-加载前的状态，loading-加载中的状态，nomore-没有更多的状态
            currentPage  : 1,
            lastPage     : 1,
            total  : '',
            classId: '',
            classnum:'',
            braceletnum:''
        };
    },
    computed: {
        ...mapGetters(['isLogin', 'userInfo']),
    },
    created() {
        // 触底监听
        uni.$on('uOnReachBottom', data => {
            if (this.currentPage < this.lastPage) {
                this.currentPage += 1;
                this.getmyGroupList();
	            console.log( this.loadStatus,"=== res.last_page:",this.lastPage," --that.currentPage:", this.currentPage)
            }
        });
    },
    onPullDownRefresh() {
    },
    onShow() {
        let that    = this;
        this.enable = true;
    },
    onHide() {
        this.enable = false;
    },
    onLoad() {
        this.classId = this.$Route.query.id;
        this.getmyGroupList()
    },
    mounted() {
    },
    watch  : {},
    methods: {
        API_URL() {
            return API_URL
        },
        // 初始化
        init() {
            this.isRefresh = false;
        },
        // 路由跳转
        jump(path, parmas) {
            console.log('-----11111');
            this.$Router.push({
                path : path,
                query: parmas
            });
        },
        // 组织成员列表
        getmyGroupList() {
            let that = this;
            that.$http('login.braceletView', {
                id: that.classId,
                page    : that.currentPage,
                pagesize: 10
            }).then(res => {
                that.myGroupList = [...that.myGroupList, ...res.data];
                that.isEmpty     = !that.myGroupList.length;
                that.lastPage    = res.last_page;
	            
                that.loadStatus  = that.currentPage < res.last_page ? 'loadmore' : 'nomore';
                this.classnum       = res.classnum
                this.braceletnum       = res.braceletnum
            });
        },
    }
};
</script>

<style lang="scss">
.home-wrap {
    padding: 0 30rpx 30rpx;
}

//nav
page {
    background: #fff;
}

.userInfo {
    margin-top: 20rpx;
    margin-bottom: 20rpx;

    .userleft {
        .usertitle {
            font-size: 30rpx;
        }
    }

    .userright {
        padding: 4rpx 24rpx;
        background: #0081ff;
        border-radius: 45rpx;
        color: #FFFFFF;
        font-size: 24rpx;
        margin: 0;
    }

}
.tablist{
    width: 100%;
    border-radius:38rpx;
    background: #fff;
    font-size:32rpx;
    .tab-item{
        &.actived{
            background:#3FA897;
            color:#fff;
            border-radius:38rpx;
        }

    }
}
.zixun-item {
    border-radius: 30rpx;
    background: #fff;
    overflow: hidden;

    .zixuntitle {
        color: #333;
        font-size: 32rpx;
    }

    .zixunimg {
        width: 100%;
        height: 180rpx;

        image {
            width: 100%;
            height: 100%;
        }
    }

    .zixuntime {
        color: #333;
        font-size: 32rpx;
    }

    .yichu {
        padding: 16rpx 26rpx;
        border-radius: 34rpx;
        background: #0081ff;
        color: #fff;
    }

    .tag {
        background: #fff;
        color: #5e00ff;
        padding: 10rpx 18rpx;
        font-size: 20rpx;
        border-radius: 34rpx;
        border: 2rpx solid #5e00ff;
    }
    .task-list{

        .task-list-item{
            width: 33%;
            color: #8E8E8E;
        }
        .task-list-items{
            width: 33%;
            font-size: 34rpx;
            color: #010101;
            text-align: center;
        }
    }
}

.detlebtn {
    height: 100%;
    background: #ff0000;
    width: 120rpx;
    border-radius: 20rpx;
}

// 提示
.notice-modal {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    width: 85vw;
    min-height: 358rpx;
    background: #ffffff;
    padding: 30rpx;
    border-radius: 20rpx;

    .notice-title {
        width: 100%;
        font-size: 30rpx;
        font-weight: bold;
        color: #46351b;
        text-align: center;
    }

    .notice-detail {
        font-size: 24rpx;
        font-weight: 400;
        color: #999999;
        line-height: 36rpx;
        margin-bottom: 50rpx;
    }

    .back-btn {
        width: 45%;
        height: 70rpx;
        line-height: 70rpx;
        background: #f8f8f8;
        box-shadow: 0 7rpx 8rpx 2rpx #ccc;
        border-radius: 35rpx;
        font-size: 26rpx;
        font-weight: 500;
        color: #333;
        margin-bottom: 10rpx;
    }

    .notice-btn {
        width: 45%;
        height: 70rpx;
        line-height: 70rpx;
        font-size: 26rpx;
        font-weight: 500;
        color: #fff;
        border-radius: 35rpx;
        background: linear-gradient(90deg, #3357DB 0%, #3469E1 47%, #3597F1 100%);
        box-shadow: 0 7rpx 8rpx 2rpx #3597F1;
    }
}
.collect-list{
    background: #fff;
    border-bottom: 1rpx solid #F5F5F5;
    .xuhao{
        width: 10%;
    }
    .xuehao{
        width: 35%;
    }
    .isbangding{
        width: 15%;
    }
    .shouhuan{
        width: 40%;
    }
}
.collect-list-top{
    background: #F5F5F5;
    color:#8E8E8E;
}


// 弹窗
.modal-box {
    width: 750rpx;
    border-radius: 30rpx 30rpx 0 0;
    background: #fff;

    .modal-head {
        height: 92rpx;
        border-bottom: 1px solid rgba(223, 223, 223, 0.5);
        padding: 0 30rpx;

        .head-title {
            font-size: 32rpx;
            font-weight: bold;
        }
    }

    .modal-content {
        padding: 0 30rpx;

        .into-item {
            width: 24%;
            margin-right: 7rpx;
            padding: 10rpx 0;
            border: 2rpx solid #f3f4f6;
            color: #333;
            border-radius: 30rpx;
            display: flex;
            justify-content: center;
            align-items: center;

            &.active {
                color: #fff;
                background: #0081ff;
            }
        }
    }

    .modal-foot {
        font-size: 24rpx;
        padding: 20rpx 0;
        font-weight: 500;
        color: rgba(153, 153, 153, 1);
        border-top: 1px solid rgba(223, 223, 223, 0.5);

        .back-btn {
            width: 45%;
            height: 70rpx;
            line-height: 70rpx;
            background: #f8f8f8;
            box-shadow: 0 7rpx 8rpx 2rpx #ccc;
            border-radius: 35rpx;
            font-size: 28rpx;
            font-weight: 500;
            color: #333;
            margin-bottom: 10rpx;
        }

        .notice-btn {
            width: 45%;
            height: 70rpx;
            line-height: 70rpx;
            font-size: 28rpx;
            font-weight: 500;
            color: #fff;
            border-radius: 35rpx;
            background: linear-gradient(90deg, #3357DB 0%, #3469E1 47%, #3597F1 100%);
            box-shadow: 0 7rpx 8rpx 2rpx #3597F1;
        }
    }
}
::v-deep .u-swipe-action{
    border-radius:30rpx;
}
.shouhuan-tishi{
    color:#FA3E3E;
    background: #FFEDED;
    border-radius: 20rpx;
}
</style>
